package com.myt.matp.gui;

import com.myt.matp.core.Event;

public final class UIButton extends UIItem {

    protected UIButton(int id, GUI gui) {
	super(id, gui);
	// Default aspect
	setBorder(1);
	setFlags(FLAG_CENTERED);
    }

    public int getType() {
	return UIWidget.BUTTON;
    }

    public boolean dispatchEvent(final Event e) {
	boolean ret = true;
	if (!dispatchEventUIButton(e)) {
	    ret = super.dispatchEvent(e);
	}
	return ret;
    }

    private boolean dispatchEventUIButton(final Event e) {
	boolean ret = false;

	switch (e.getId()) {
	case Event.UI_KEY_PRESSED:
	    ret = eventUIKeyPressed(e);
	    break;
	}

	return ret;
    }

    private boolean eventUIKeyPressed(final Event e) {
	boolean ret = false;
	switch (e.getWParam()) {
	case GUI.KEY_OK:
	    // visual efects
	    ret = true;
	}
	return ret;
    }

}